﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebTraderLiteCL
{
    public class AutoTransaction : Transaction
    {
        enum transactions { AUTOBUY, AUTOSELL, AUTOWATCH };

        public AutoTransaction(string transactionType, Stock stock, int numShares)
        {
            this.stock = stock;
            this.transType = transactionType;
            this.noShares = numShares;
        }
        public AutoTransaction(string transactionType, Stock stock, int numShares,string user, string trend, float bprice)
        {
            //need to add user to definition
            this.stock = stock;
            this.transType = transactionType;
            this.noShares = numShares; //not used by autowatch, pass null or 0
            //this.user = user;
            this.price = bprice;
            this.username = user;
            this.trendtomonitor = trend;
        }
        public override int Execute()
        {
            if (this.transType == transactions.AUTOBUY.ToString())
            {
                //autobuy
                DBTransactions trans = new DBTransactions();
                trans.insertIntoAutoBuy(this.stock, this.noShares, this.username, this.trendtomonitor,this.price);
                //trans.deductandAddbrokerFees(this.username);
            }
            else if (this.transType == transactions.AUTOSELL.ToString())
            {
                //autosell
                DBTransactions trans = new DBTransactions();
                trans.insertIntoAutoSell(this.stock, this.noShares, this.username, this.trendtomonitor, this.price);
                //trans.deductandAddbrokerFees(this.username);

            }
            else
            {
                //autowatch

            }

            return (0);
        }
    }
}
